
Version:=1.3.7
ModuleName:=iptables

Objcet:=$(ModuleName).tgz
ObjectDir:=$(ModuleName)-$(Version)
ObjcetSource:=$(ModuleName)-$(Version).tar.bz2

ModuleName2:=l7-protocols
Version2:=2008-02-20
Objcet2:=$(ModuleName2).tgz
ObjectDir2:=$(ModuleName2)-$(Version2)
ObjcetSource2:=$(ModuleName2)-$(Version2).tar.gz

PatchFileName:=iptables-1.3-for-kernel-2.6.20forward-layer7-2.17.patch

DependFiles:=

InstallDirTmp:=usr/local
InstallDir:=/$(InstallDirTmp)
InstallBin:=$(InstallDir)/bin
InstallBinTmp:=$(InstallDirTmp)/bin
InstallLib:=$(InstallDir)/lib
InstallLibTmp:=$(InstallDirTmp)/lib
InstallMan:=$(InstallDir)/man

KernelDir:=$(shell cd ../kernel/linux-2.6.20.7; pwd )

PatchCommand:=cd $(ObjectDir) && patch -p1 <../$(PatchFileName) && chmod +x ./extensions/.layer7-test && cd ../
Config:=BINDIR=$(InstallBin)/ LIBDIR=$(InstallLib) MANDIR=$(InstallMan) \
	KERNEL_DIR=$(KernelDir) #NO_SHARED_LIBS=1 #DO_MULTI=1
.PHONY: all clean dist_clean


all:$(Objcet) $(Objcet2)

$(Objcet):$(ObjcetSource)
	$(MAKE) -C ../kernel/
	tar -xf $(ObjcetSource)
	$(PatchCommand)
	$(MAKE) -C $(ObjectDir) $(Config) install DESTDIR=../
	rm -rf usr/local/man usr/local/bin/ip6tables \
		usr/local/bin/iptables-restore \
		usr/local/bin/iptables-save \
		usr/local/bin/iptables-xml 
	tar -cvzf $(Objcet) usr

$(Objcet2):$(ObjcetSource2)
	rm -rf usr etc && mkdir usr etc
	tar -xf $(ObjcetSource2)
	$(MAKE) -C $(ObjectDir2) install PREFIX=../usr/local/
	cp -rf usr/local/etc/l7-protocols ./etc/
	tar -czvf $(Objcet2) usr etc

clean:
	rm -rf usr $(Objcet) etc $(Objcet2)

dist_clean:clean
	rm -rf $(ObjectDir) $(ObjcetSource)  $(ObjectDir2) $(ObjcetSource2) *.tar.gz
	
include ../Makefile.Res
